# class Books:
#     def __init__(self, title, author, punlish_date):  # 定义属性
#         self.title = title
#         self.author = author
#         self.publish_date = punlish_date
#
#     def get_title(self):  # 获取书名
#         return self.title
#
#     def get_author(self):  # 获取作者
#         return self.author
#
#     def get_publish_date(self):  # 获取日期
#         return self.publish_date
#
# class Library:
#
#     def __init__(self):  #定义全部图书列表和借出书的列表
#         self.all = []
#         self.borrow = []
#
#     def add_books(self,book):  # 添加书籍
#         if book not in self.all:
#             self.all.append(book)
#             print(f"{book.get_title()}已添加")
#         else:
#             print("书已存在")
#
#     def borrow_book(self, name):  # 借书
#         if name in self.all:
#             self.all.remove(name)
#             self.borrow.append(name)
#             print(f"{name.get_title()}已借出")
#         else:
#             print("书不存在")
#
#     def return_book(self, book):  # 还书
#         if book in self.borrow:
#             self.all.append(book)
#             print(f"{book.get_title()}已归还")
#         else:
#             print("归还书不存在")
#
#     def show_books(self):  # 展示书
#         if self.all:
#             for b in self.all:
#                 print(f"书名是{b.get_title()}, 作者是{b.get_author()}, 日期是{b.get_publish_date()}")
#         else:
#             print("没有书")
# # 添加Books实例对象
# b1 = Books("a", "Tom", "1-15")
# b2 = Books("b", "Jay", "1-16")
# print(b1.get_title())
# print(b1.get_author())
# print(b1.publish_date)
# # 添加Library实例对象
# b3 = Library()
# # 添加
# b3.add_books(b1)
# b3.add_books(b2)
# # 借出
# b3.borrow_book(b1)
# # 归还
# b3.return_book(b1)
# # 展示
# b3.show_books()


# class Employee:
#     def __init__(self, hour, wage):  # 定义属性 工时和时薪
#         self.hour = hour
#         self.wage = wage
#
#     def calculate_salary(self):  # 计算薪资
#         pass
#
# class FullTimeEmployee(Employee):
#     def calculate_salary(self):  # 计算全职员工的薪资
#         print(f"全职员工的薪资是：{self.hour * self.wage}")
#
# class PartTimeEmployee(Employee):
#     def calculate_salary(self):  # 计算兼职员工的薪资
#         print(f"兼职员工的薪资是：{self.hour * self.wage}")
# # 获取全职和兼职的对象
# f = FullTimeEmployee(160, 100)
# p = PartTimeEmployee(80, 50)
# # 子类实例调用子类的方法
# f.calculate_salary()
# p.calculate_salary()


class Hero:
    def __init__(self, name, blood_flow, damage):  # 定义属性 血量为私有属性
        self.name = name
        self.__blood_flow = blood_flow
        self.damage = damage

    def skill(self):
        pass

    def attacked(self, hero):
        return self.__blood_flow - hero.skill()

    def deliver_line(self):  # 实例方法为讲台词
        pass

class Master(Hero):
    def __init__(self, name, blood_flow, damage, magic):  # 重写英雄类构造方法
        super().__init__(name, blood_flow, damage)
        self.magic = magic  # 法师增加魔力属性

    def skill(self):
        return self.magic + self.damage

    def deliver_line(self):
        super().deliver_line()
        print("我是法师")

    def put_kill(self):  # 实例方法放技能
        if self.magic > 5:
            print(f"{self.name}成功释放技能")
        else:
            print("不能释放技能")

# 获取子类对象
m = Master("王昭君", 100, 15, 30)
h = Hero("英雄1", 80, 20)
# 子类实例调用子类的方法
m.deliver_line()
m.put_kill()
print(f"{m.name}使用技能对{h.name}造成{m.skill()}点伤害。")
print(f"该回合结束后{h.name}剩余血量为{h.attacked(m) }")
















